package com.java.zhuiyun.api.course_pc.controller;

import com.java.zhuiyun.api.course_pc.service.CoursePcService;
import com.java.zhuiyun.common.response.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CoursePcController
 * @Description TODO
 * @Author wuwan
 * @Date 2023/8/21 11:49
 **/
@RestController
@CrossOrigin
@RequestMapping("/CoursePc")
public class CoursePcController {
    @Autowired
    private CoursePcService coursePcService;

    /*
     * @Author wuwan
     * @Description 查询课程
     * @Date 2023/8/21 15:02
     * @Return
     * @param null
     */
    @GetMapping("/getTeacher")
    public CommonResult getTeacher(Integer id) {//todo 教师id
        return CommonResult.ok(coursePcService.getTeacher(id));
    }

    /*
     * @Author wuwan
     * @Description 查询课程
     * @Date 2023/8/21 15:02
     * @Return
     * @param null
     */
    @GetMapping("/selectCourse")
    public CommonResult selectCourse(Integer tid) {//todo 课程id
        CommonResult commonResult = coursePcService.selectCourse(tid);
        return CommonResult.ok(commonResult);
    }
    /*
     * @Author wuwan
     * @Description 查询章节
     * @Date 2023/8/21 15:02
     * @Return
     * @param null
     */
    @GetMapping("/selectUnit")
    public CommonResult selectUnit() {
        return CommonResult.ok(coursePcService.selectUnit());
    }
    /*
    * @Author wuwan
    * @Description 视频查询
    * @Date 2023/8/22 14:20
    * @Return
    * @param null
    */
    @GetMapping("/playVideo")
    public CommonResult playVideo(Integer fid) {//todo 视频id
        return CommonResult.ok(coursePcService.playVideo(fid));
    }
    /*
    * @Author wuwan
    * @Description 课程购买
    * @Date 2023/8/23 19:02
    * @Return
    * @param null
    */
    @PostMapping("/buyCourse")
    public CommonResult buyCourse(Integer cid,Integer uid){ //todo Cid课程主键 uid用户主键
        return CommonResult.ok(coursePcService.buyCourse(cid,uid));
    }
    /*
    * @Author wuwan
    * @Description 查询用户信息
    * @Date 2023/8/24 9:52
    * @Return
    * @param null
    */
    @GetMapping("/queryByUser")
    public CommonResult queryByUser(Integer userId){
        return CommonResult.ok(coursePcService.queryByUser(userId));
    }
}
